package net.funwoo.pandago.util;

/**
 * Created by Administrator on 2015/5/6.
 */
public class StringUtils {
    private static final String REGEX_PHONE = "^0?(13[0-9]|15[012356789]|18[0236789]|14[57])[0-9]{8}$";
    private static final String REGEX_EMAIL = "^[a-zA-Z0-9_\\.]+@[a-zA-Z0-9-]+[\\.a-zA-Z]+$";

    public static boolean isIdValid(String id) {
        return isPhoneText(id) || id.matches(REGEX_EMAIL);
    }

    public static boolean isPhoneText(String text) {
        return text.matches(REGEX_PHONE);
    }

    public static boolean isEmpty(CharSequence charSequence) {
        if (charSequence == null || charSequence.length() == 0) {
            return true;
        } else {
            // space check
            return charSequence.toString().trim().length() == 0;
        }
    }
}
